<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>单周期数据通路实验（Ⅱ） :: 计算机组成原理实验指导</title>
    <meta name="generator" content="Antora 3.2.0-alpha.8">
    <link rel="stylesheet" href="../../../_/css/site.css">
<!--    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> -->
  </head>
  <body class="article">
<header class="header">
  <nav class="navbar">
    <div class="navbar-brand">
      <a class="navbar-item" href="../../..">计算机组成原理实验指导</a>
      <button class="navbar-burger" aria-controls="topbar-nav" aria-expanded="false" aria-label="Toggle main menu">
        <span></span>
        <span></span>
        <span></span>
      </button>
    </div>
    <div id="topbar-nav" class="navbar-menu">
      <div class="navbar-end">

        <div class="navbar-item">
          <span class="control">
            <a class="button is-primary" href="https://gitee.com/fpga-lab/digisimlab-open" target="_blank">Download</a>
          </span>
        </div>
      </div>
    </div>
  </nav>
</header>
<div class="body">
<div class="nav-container" data-component="digisimlab" data-version="1.1">
  <aside class="nav">
    <div class="panels">
<div class="nav-panel-menu is-active" data-panel="menu">
  <nav class="nav-menu">
    <button class="nav-menu-toggle" aria-label="Toggle expand/collapse all" style="display: none"></button>
    <h3 class="title"><a href="../index.html">计算机组成原理实验指导</a></h3>
<ul class="nav-list">
  <li class="nav-item" data-depth="0">
<ul class="nav-list">
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../index.html">前言</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="0">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">Digital仿真软件使用指南</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-brief-introduction.html">简介</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../introduce-digitalsim.html">下载、安装及启动</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-getting-started.html">新手入门</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-generate-circuit.html">电路生成</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-test-circuit.html">电路测试</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-sim-dff.html">时序电路仿真</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-other-useful.html">几个有用的组件</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-hierarchical-design.html">层次化设计</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="../ds-parametric-design.html">参数化设计</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="0">
<ul class="nav-list">
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">基本逻辑电路</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="bl-multiplexer.html">多路选择器实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="bl-decoder.html">译码器实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="bl-register.html">触发器和寄存器实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="bl-counter.html">计数器实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">运算电路</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="op-add_sub_operation.html">加减运算电路实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="op-arithmetic_logic_unit.html">算术逻辑单元实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="op-compare.html">比较运算电路实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">存储器</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="mem-rom.html">ROM实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="mem-ram.html">RAM实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="dp-register_file.html">寄存器堆实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="mem-path.html">存储器应用实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">数据通路</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="dp-overview.html">概述</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="dp-single_cycle_datapath.html">单周期数据通路实验（Ⅰ）</a>
  </li>
  <li class="nav-item is-current-page" data-depth="2">
    <a class="nav-link" href="dp-single_cycle_datapath-2.html">单周期数据通路实验（Ⅱ）</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">控制器</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="cu-overview.html">概述</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="cu-hardwire_controller-1.html">硬布线控制实验（Ⅰ）</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="cu-hardwire_controller.html">硬布线控制实验（Ⅱ）</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="cu-hardwire_controller-3.html">硬布线控制实验（Ⅲ）</a>
  </li>
</ul>
  </li>
</ul>
  </li>
</ul>
  </nav>
</div>
<div class="nav-panel-explore" data-panel="explore">
  <div class="context">
    <span class="title">计算机组成原理实验指导</span>
    <span class="version">1.1</span>
  </div>
  <ul class="components">
    <li class="component is-current">
      <div class="title"><a href="../../index.html">计算机组成原理实验指导</a></div>
      <ul class="versions">
        <li class="version is-latest">
          <a href="../../index.html">1.31</a>
        </li>
        <li class="version">
          <a href="../../1.2/index.html">1.2</a>
        </li>
        <li class="version is-current">
          <a href="../index.html">1.1</a>
        </li>
        <li class="version">
          <a href="../../1.0/index.html">1.0</a>
        </li>
      </ul>
    </li>
  </ul>
</div>
    </div>
  </aside>
</div>
<main class="article">
<div class="toolbar" role="navigation">
<button class="nav-toggle"></button>
  <a href="../../index.html" class="home-link"></a>
<nav class="breadcrumbs" aria-label="breadcrumbs">
  <ul>
    <li><a href="../index.html">计算机组成原理实验指导</a></li>
    <li>数据通路</li>
    <li><a href="dp-single_cycle_datapath-2.html">单周期数据通路实验（Ⅱ）</a></li>
  </ul>
</nav>
<div class="page-versions">
  <button class="version-menu-toggle" title="Show other versions of page">1.1</button>
  <div class="version-menu">
    <a class="version" href="../../lab/dp-single_cycle_datapath-2.html">1.31</a>
    <a class="version" href="../../1.2/lab/dp-single_cycle_datapath-2.html">1.2</a>
    <a class="version is-current" href="dp-single_cycle_datapath-2.html">1.1</a>
    <a class="version is-missing" href="../../1.0/index.html">1.0</a>
  </div>
</div>
</div>
  <div class="content">
<aside class="toc sidebar" data-title="页内目录" data-levels="2">
  <div class="toc-menu"></div>
</aside>
<article class="doc">
<h1 class="page">单周期数据通路实验（Ⅱ）</h1>
<div class="sect1">
<h2 id="_实验目的"><a class="anchor" href="#_实验目的"></a>实验目的</h2>
<div class="sectionbody">
<div class="paragraph">
<p>1．理解单周期数据通路的组成结构。</p>
</div>
<div class="paragraph">
<p>2．掌握单周期数据通路信息加工过程。</p>
</div>
<div class="paragraph">
<p>3．锻炼分析问题与解决问题的能力。</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_实验原理"><a class="anchor" href="#_实验原理"></a>实验原理</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="#fig-dp-2">图 1</a>是本实验的单周期数据通路，该数据通路使用了前面实验中的ALU、三端口寄存器堆和RAM存储器。
ALU输入端X的运算数据来自寄存器堆的RD1读端口，另一个输入端Y的运算数据可以来自寄存器堆的RD2读端口，或者来自立即数；ALU的运算结果F可以作为寄存器堆的写数据WD，也可以作为存储器的地址A。
DI是存储器的数据输入端口，写入存储器的数据由寄存器堆的RD2读端口提供。
寄存器堆写端口WD的数据除了可以来自ALU的运算结果，也可以来自存储器的读出数据DO。
该数据通路可以在一个周期内完成一次完整的ALU运算或者一次存储器访问，这里所说的“完整的ALU运算”包括从寄存器堆读数据、ALU运算、运算结果保存到寄存器堆。</p>
</div>
<div id="fig-dp-2" class="imageblock">
<div class="content">
<img src="_images/dp-datapath-2.png" alt="单周期数据通路">
</div>
<div class="title">图 1. 单周期数据通路</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_实验任务"><a class="anchor" href="#_实验任务"></a>实验任务</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>设计</p>
<div class="paragraph">
<p>用Digital仿真软件按照<a href="#fig-dp-2">图 1</a>绘制电路图。
<a href="op-arithmetic_logic_unit.html" class="xref page">ALU</a>和<a href="dp-register_file.html" class="xref page">三端口寄存器堆</a>使用前面实验完成的。
存储器使用<a href="mem-ram.html" class="xref page">存储器实验</a>中已经熟悉的RAM组件。</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="注"></i>
</td>
<td class="content">
图中存储器的OE端口也可以固定接常量1，即始终读出。
</td>
</tr>
</table>
</div>
</li>
<li>
<p>仿真</p>
<div class="paragraph">
<p>通过仿真验证数据通路，并保存仿真过程数据文件。</p>
</div>
<div class="olist loweralpha">
<ol class="loweralpha" type="a">
<li>
<p>数据写入寄存器堆</p>
<div class="paragraph">
<p>将2个常数存入R1、R2寄存器。</p>
</div>
<div class="paragraph">
<p>常数通过ImmediateData输入引脚送入。从<a href="#fig-dp-2">图 1</a>可以看出，ImmediateData并没有直接连在寄存器堆的写端口，而是经过多路器后送到了ALU的Y输入端；所以要将ImmediateData送到寄存器堆的写端口，必须经过ALU。在前面寄存器堆的实验中已经设计R0寄存器的值恒为0，可以用ALU将ImmediateData加上R0寄存器值，将ImmediateData传送到寄存器堆的写端口。</p>
</div>
<div class="admonitionblock caution">
<table>
<tr>
<td class="icon">
<i class="fa icon-caution" title="注意"></i>
</td>
<td class="content">
<div class="paragraph">
<p>存入的常数应有助于判别下面将要验证的各种运算结果是否正确，可参考<a href="op-add_sub_operation.html" class="xref page">加减运算电路实验</a>。</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>可以手动操作完成验证，或者编写测试用例（test case）进行电路测试。
<a href="#exa-test-dp2">例 1</a>给出了将“5”存入R1寄存器的测试数据。</p>
</div>
<div id="exa-test-dp2" class="exampleblock">
<div class="title">例 1. 将“5”存入R1寄存器</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">Clk RegWr WA RA1 RA2 IM  Ysel M  S1 S0  MemWr WDsel F   S  Z  C  O
C   1     1  0   0   0x5 1    0  0  0   0     0     0x5 0  0  0  0 <i class="conum" data-value="1"></i><b>(1)</b>
0   0     0  1   0   0   0    0  0  0   0     0     0x5 0  0  0  0 <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>将“5”写入R1寄存器；</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>读出R1。</td>
</tr>
</table>
</div>
</div>
</div>
</li>
<li>
<p>寄存器数据写入RAM</p>
<div class="paragraph">
<p>将R1和R2寄存器的内容，分别写入到存储器的0号单元和1号单元中。即</p>
</div>
<div class="paragraph">
<p>R1 → Mem[0];</p>
</div>
<div class="paragraph">
<p>R2 → Mem[1];</p>
</div>
</li>
<li>
<p>完成各种ALU运算，并将结果存入存储器的2~7号单元。即</p>
<div class="paragraph">
<p>R1 + R2 → R3; R3 → Mem[2];</p>
</div>
<div class="paragraph">
<p>R1 − R2 → R3; R3 → Mem[3];</p>
</div>
<div class="paragraph">
<p>R1 &amp; R2 → R3; R3 → Mem[4];</p>
</div>
<div class="paragraph">
<p>R1 | R2 → R3; R3 → Mem[5];</p>
</div>
<div class="paragraph">
<p>R1 ⊕  R2 → R3; R3 → Mem[6];</p>
</div>
<div class="paragraph">
<p>R2 ⊕ 0b1111 → R3; R3 → Mem[7];</p>
</div>
</li>
<li>
<p>依次读出存储器的0~7号单元内容并验证结果是否正确。</p>
</li>
<li>
<p>设计更复杂的数据通路操作。</p>
<div class="paragraph">
<p>例如，将两个存储单元的内容相加，结果存入另一存储单元。</p>
</div>
</li>
</ol>
</div>
</li>
<li>
<p>实验结果分析</p>
<div class="paragraph">
<p>对实验结果进行详细分析说明，并给出结论。</p>
</div>
<div class="paragraph">
<p>若结果与预期不符，尝试独立分析故障现象并排除故障，锻炼分析问题与解决问题的能力。</p>
</div>
</li>
</ol>
</div>
<div class="sidebarblock text-center">
<div class="content">
<div class="title">许可 | License</div>
<div class="paragraph">
<p><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA：署名-非商业性使用-相同方式共享 4.0 国际许可协议</a></p>
</div>
<div class="paragraph">
<p>作者：
肖铁军 &lt;<a href="mailto:xiaotiejun@foxmail.com.cn">xiaotiejun@foxmail.com.cn</a>&gt;</p>
</div>
</div>
</div>
</div>
</div>
</article>
  </div>
</main>
</div>
<footer class="footer">
  <p>This page was built using the Antora default UI.</p>
  <p>The source code for this UI is licensed under the terms of the MPL-2.0 license.</p>
</footer>
<script id="site-script" src="../../../_/js/site.js" data-ui-root-path="../../../_"></script>
<script async src="../../../_/js/vendor/highlight.js"></script>
  </body>
</html>
